package tools

import "os"

// Exportable constants.
const (
	ExitOk  = 0
	ExitErr = 1
)

// Exit represents compatible to os.Exit function to call.
var Exit = os.Exit

// ExitOnErr calls os exit, if error is nil uses zero exit code (ExitOk),
// otherwise 1 (ExitErr).
func ExitOnErr(err error) {
	if err == nil {
		Exit(ExitOk)
	} else {
		Exit(ExitErr)
	}
}
